<template>
  <div ref="mainCon" class="container">
    <topTitle
      v-if="!hiddleToolBar"
      :titleText="titleText"
      :titleExplain="titleExplain"
    ></topTitle>
    <div class="mainCon">
      <el-row class="toolbar searchInputWidth" style="padding-bottom: 0">
        <el-form :inline="true" :model="filterField" ref="searchConditions">
          <el-col :lg="8" :xl="6">
            <el-form-item label="企业" class="row-padding-bottom">
              <el-input
                v-model="filterField.uscc"
                placeholder="输入企业或统一社会信用代码"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-form-item>
            <el-button
              type="primary"
              icon="icon iconfont iconchazhao1"
              @click="searchList"
              class="searchBtn"
            >
              <span>搜索</span>
            </el-button>
          </el-form-item>
          <el-form-item>
            <exportBtn
              :dataLen="tableList.length"
              :filterField="filterField"
              api="api-s/report/export_JC_CS_CONSTRUCTION"
            ></exportBtn>
          </el-form-item>
        </el-form>
      </el-row>
      <div class="spacing"></div>
      <div
        ref="tableBox"
        :class="hiddleToolBar ? 'tableBoxCur tableBox' : 'tableBoxCur'"
      >
        <el-table
          :data="tableList"
          ref="tableBox1"
          :max-height="tableHeight"
          v-loading="loading"
          @sort-change="sortChange"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          highlight-current-row
          stripe
          style="border: 1px solid #dfe6ec"
        >
          <el-table-column prop="companyName" label="企业名称" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.companyName"
                :columnName="'companyName'"
              ></copyText>
            </template>
          </el-table-column>
          <el-table-column
            prop="uscc"
            label="统一社会信用代码"
            align="center"
            :formatter="formatTd"
            min-width="150"
          ></el-table-column>
          <el-table-column
            prop="totalProjCount"
            label="参建项目总数（个）"
            sortable="custom"
            align="center"
            :formatter="formatTd"
            min-width="130"
          ></el-table-column>
          <el-table-column
            prop="startedProjCount"
            label="参建开工项目总数（个）"
            align="center"
            :formatter="formatTd"
            min-width="150"
          ></el-table-column>
          <el-table-column
            label="操作"
            align="left"
            :formatter="formatTd"
            fixed="right"
            width="200px"
          >
            <template slot-scope="scope">
              <el-link
                type="primary"
                v-hasBtn="['mProjectCompany:detail', 'projectList:detail']"
                @click="toDetail(scope.row)"
                >查看详情</el-link
              >
              <!-- <span v-show="!isShowDetail">--</span> -->
            </template>
          </el-table-column>
          <!-- 表格数据为空时，页面显示 -->
          <div slot="empty" v-show="isShow">
            <emptyTable emptyText="暂无相关信息"></emptyTable>
          </div>
        </el-table>
        <!-- filterField为搜索条件 -->
        <!-- getTableList为获取子组件的数据 -->
        <Pagination
          ref="pagination"
          @getList="getTableList"
          :filterField="filterField"
          :requestUrl="requestUrl"
        ></Pagination>
      </div>
    </div>
  </div>
</template>

<script>
import scrollTable from '@/mixin/scrollTable.js'

export default {
  name: 'constructEmployingUnitList',
  mixins: [scrollTable],
  data() {
    return {
      titleText: '参建单位',
      titleExplain:
        '可查看管辖行政区划内，有参建项目的用工单位，参建项目个数也仅统计行政区划内的',
      //表格数据
      tableList: [],
      requestUrl: 'api-p/projectcompany/expand/construction',
      date: [],
      //搜索条件
      filterField: {
        uscc: '', //uscc
      },
      isShow: false, //列表加载
      loading: true,
      // isShowDetail: ""
    }
  },
  created() {
    this.$nextTick(function () {
      this.$refs.pagination.getTableListData()
    })
    // this.isShowDetail = this.$store.state.buttonLimitsArr.indexOf('projectList:detail') > -1 || this.$store.state.buttonLimitsArr.indexOf('mProjectCompany:detail') > -1;
  },
  methods: {
    getTableList(data) {
      this.tableList = data
      this.loading = false
      if (this.tableList.length < 1) {
        this.isShow = true
      }
    },
    // 搜索
    searchList() {
      this.$refs.pagination.getTableListData()
    },
    //查看详情
    toDetail(row) {
      this.$router.push({
        path: '/home/constructEmployingUnit/constructEmployingUnitDetail',
        name: 'constructEmployingUnitDetail',
        query: {
          uscc: row.uscc,
          companyName: row.companyName,
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/constructEmployingUnit/constructEmployingUnitList',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
  },
}
</script>

<style lang="less" scoped>
.mainCon {
  top: 210px;
  @media only screen and (max-width: 1366px) {
    /deep/.searchInputWidth .el-form--inline .el-form-item__label {
      width: 80px;
    }
  }
}
@import '../../../static/css/filterArea.less';
</style>
